#include <iostream>
#include <thread>
#include <future>

struct Num
{
    int first_;
};

class Singleton final
{
public:
    static Singleton& GetInstance()
    {
        static Singleton sg;
        return sg;
    }

    void Initial()
    {
        try
        {
            // int *i = nullptr;
            // *i = 100;
            std::cout << "Initial is called" << std::endl;
            Num nu{10};
            //sp_ = std::promise<Num>(); // 这里会引发 std::future_error: Broken promise
            sp_.set_value(nu);
            // Floating point exception
            // int j = 100;
            // j = j/0; 
        }
        catch(const std::exception& e)
        {
            std::cerr << e.what() << '\n';
        }
        
    }
    std::promise<Num> sp_;
};